{% extends "BluehouseappWebBundle:Backend/Admin/layout:layout.html.twig" %}
{% from 'BluehouseappWebBundle:Macros:misc.html.twig'  import pagination %}
{% import 'BluehouseappWebBundle:Macros:buttons.html.twig' as buttons %}


{% block title %}
    节点管理
{% endblock %}
{% block body -%}
{%  set entities=nodes %}
    <div class="page-header">
        <h2>节点管理 <small></small></h2>
    </div>
    <ol class="breadcrumb clearfix">
        <div class="clearfix">
            <div class="pull-left">
                {{ buttons.create(path('bluehouseapp_node_new')) }}
            </div>
        </div>
    </ol>

    {{ pagination(entities) }}
    <table class="table  table-striped table-hover table-condensed">
        <thead>
            <tr>
                <th>{{bluehouse_resource_sort('name', '名称') }}</th>
                <th>代码</th>
                <th>头像</th>
                <th>描述</th>
                <th>{{bluehouse_resource_sort('enabled', '状态') }}</th>
                <th>{{bluehouse_resource_sort('no', '显示序号') }}</th>
                <th>所属分类</th>
                <th>最后更新时间</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
        {% for entity in entities %}
            <tr>
                <td><a href="{{ path('bluehouseapp_node_show', { 'id': entity.id }) }}">{{ entity.name }}</a></td>
                <td>   {{ entity.code }}
                </td>
                <td>
                {% if entity.attachment %}
                <img  class="box_avatar" border="0"  align="default" src="{{vich_uploader_asset(entity,'image')|imagine_filter('avatar_image')}}"/>
                {% endif %}
                </td>
                <td>
                    {{ entity.description }}
                </td>
                <td>
                {% if entity.enabled %}
                    <span class="label label-success">正常</span>
                {% else %}
                    <span class="label label-danger">已禁用</span>
                {% endif %}
                </td>
                <td>{{ entity.no }}</td>
                <td>{{ entity.category.name }}</td>
                <td>{% if entity.modified %}{{ entity.modified|date('Y-m-d H:i:s') }}{% endif %}</td>
                <td>
                <ul>

                    <li>
                        {{ buttons.edit(path('bluehouseapp_node_edit', { 'id': entity.id })) }}
                    </li>

                    <li>
                    {% if entity.enabled %}
                        {{ buttons.disable(path('bluehouseapp_node_disable',{id:entity.id})) }}

                    {% else %}
                        {{ buttons.enable(path('bluehouseapp_node_enable',{id:entity.id})) }}
                    {% endif %}
                    </li>
                    <li>
                        {{ buttons.delete(path('bluehouseapp_node_delete',{id:entity.id})) }}
                    </li>
                </ul>
                </td>
            </tr>
        {% endfor %}
        </tbody>
    </table>

    {{ pagination(entities) }}
    {% endblock %}
